/**
 * @param {string} s
 * @return {number}
 */
var lengthOfLongestSubstring = function(s) {
  let len = s.length > 0 ? 1 : 0
  for (let i = 0; i < s.length; i++) {
    let twice = 0
    // 起始值
    let text = s[i]
    for (let j = (i + 1); j < s.length; j++) {
      if (text.indexOf(s[j]) < 0) {
        text += s[j]
        twice = text.length
        len = twice > len ? twice : len
      } else {
        break
      }
    }
  }
  return len
};